##Study_1_SSI_analysis_and_figures.R
##regressions for paper and appendix
##plots marginal effects of regression tables
##R version 3.6.1 


##set working directory where files are located
setwd("...")  ##SET WORKING DIRECTORY HERE

library(haven)

data1<- read_dta("Study_1_Agenda_Clean_SSI.dta")
names(data1)

#############################################
##    Regressions in paper and appendix    ##
#############################################
##Rename variables to match study 2

summary(as.factor(data1$answer_main))

data1$treatment_bipart<- ifelse(data1$full_treatment==1, 1, 0)
data1$treatment_min<- ifelse(data1$full_treatment==2, 1, 0)
summary(as.factor(data1$treatment_bipart))
summary(as.factor(data1$treatment_min))

##majrel = 2 if minority voter
data1$maj_other<- ifelse(data1$majrel==2, 1, 0)
summary(as.factor(data1$maj_other))

data1$policy_sent<- ifelse(data1$policy==2, 1, 0)
summary(as.factor(data1$policy))
summary(as.factor(data1$policy_sent))

##DVs
data1$bill<- data1$o_bill
data1$cong<- data1$o_cong
data1$ft_maj<- data1$o_warm_maj_01


##NOTE: instead of pid3!="Ind" use ispureind==0

###############################
##Pool all conditions, include independents - Table 2

##bill evaluation
reg2.bill<- lm(bill ~ treatment_bipart + treatment_min + policy_sent,
               data=data1,
               subset=c(data1$answer_main==1))
summary(reg2.bill) 

##congress
reg2.cong<- lm(cong ~ treatment_bipart + treatment_min + policy_sent,
               data=data1,
               subset=c(data1$answer_main==1))
summary(reg2.cong) 

##feelings toward majority
reg2.maj<- lm(ft_maj ~ treatment_bipart + treatment_min + policy_sent,
              data=data1,
              subset=c(data1$answer_main==1))
summary(reg2.maj) 

##substnative effects
sd(data1$bill[data1$answer_main==1])
##bipart
-0.06109/0.2550371 ##-0.239
##minority
-0.05154/0.2550371 ##-0.202

###############################
##Pool all conditions, exclude independents - Table 3

##bill evaluation
reg3.bill<- lm(bill ~ treatment_bipart*maj_other + treatment_min*maj_other + policy_sent,
               data=data1,
               subset=c(data1$ispureind==0 & data1$answer_main==1))
summary(reg3.bill) 

##congress
reg3.cong<- lm(cong ~ treatment_bipart*maj_other + treatment_min*maj_other + policy_sent,
               data=data1,
               subset=c(data1$ispureind==0 & data1$answer_main==1))
summary(reg3.cong) 

##feelings toward majority
reg3.maj<- lm(ft_maj ~ treatment_bipart*maj_other + treatment_min*maj_other + policy_sent,
              data=data1,
              subset=c(data1$ispureind==0 & data1$answer_main==1))
summary(reg3.maj) 

##substantive effects
sd(data1$bill[data1$answer_main==1 & data1$ispureind==0]) 
##bipart
-0.09133/0.2641836 ##-0.3457
##minority
-0.08131/0.2641836 ##-0.3077

##########################################
##Appendix Tables

##Manipulation check correct - Table E1
##bill evaluation
reg3.manip.bill<- lm(bill ~ treatment_bipart*maj_other + treatment_min*maj_other + policy_sent,
               data=data1,
               subset=c(data1$ispureind==0 & data1$answer_main==1 & data1$manip_correct==1))
summary(reg3.manip.bill) 

##congress
reg3.manip.cong<- lm(cong ~ treatment_bipart*maj_other + treatment_min*maj_other + policy_sent,
               data=data1,
               subset=c(data1$ispureind==0 & data1$answer_main==1 & data1$manip_correct==1))
summary(reg3.manip.cong) 

##feelings toward majority
reg3.manip.maj<- lm(ft_maj ~ treatment_bipart*maj_other + treatment_min*maj_other + policy_sent,
              data=data1,
              subset=c(data1$ispureind==0 & data1$answer_main==1 & data1$manip_correct==1))
summary(reg3.manip.maj) 

#######################
##Strong partisans - Table E2
##bill evaluation
reg3.stpart.bill<- lm(bill ~ treatment_bipart*maj_other + treatment_min*maj_other + policy_sent,
                     data=data1,
                     subset=c(data1$ispureind==0 & data1$answer_main==1 & data1$isstrongpar==1))
summary(reg3.stpart.bill) 

##congress
reg3.stpart.cong<- lm(cong ~ treatment_bipart*maj_other + treatment_min*maj_other + policy_sent,
                     data=data1,
                     subset=c(data1$ispureind==0 & data1$answer_main==1 & data1$isstrongpar==1))
summary(reg3.stpart.cong) 

##feelings toward majority
reg3.stpart.maj<- lm(ft_maj ~ treatment_bipart*maj_other + treatment_min*maj_other + policy_sent,
                    data=data1,
                    subset=c(data1$ispureind==0 & data1$answer_main==1 & data1$isstrongpar==1))
summary(reg3.stpart.maj) 

#######################
##Above the median for political knowledge - Table E3
##bill evaluation
reg3.know.bill<- lm(bill ~ treatment_bipart*maj_other + treatment_min*maj_other + policy_sent,
                     data=data1,
                     subset=c(data1$ispureind==0 & data1$answer_main==1 & data1$k_correct_sum_tophalf==1))
summary(reg3.know.bill) 

##congress
reg3.know.cong<- lm(cong ~ treatment_bipart*maj_other + treatment_min*maj_other + policy_sent,
                     data=data1,
                     subset=c(data1$ispureind==0 & data1$answer_main==1 & data1$k_correct_sum_tophalf==1))
summary(reg3.know.cong) 

##feelings toward majority
reg3.know.maj<- lm(ft_maj ~ treatment_bipart*maj_other + treatment_min*maj_other + policy_sent,
                    data=data1,
                    subset=c(data1$ispureind==0 & data1$answer_main==1 & data1$k_correct_sum_tophalf==1))
summary(reg3.know.maj) 

#######################
##Indepenents - Table E4
##bill evaluation
reg2.ind.bill<- lm(bill ~ treatment_bipart + treatment_min + policy_sent,
               data=data1,
               subset=c(data1$answer_main==1 & data1$isindep==1))
summary(reg2.ind.bill) 

##congress
reg2.ind.cong<- lm(cong ~ treatment_bipart + treatment_min + policy_sent,
               data=data1,
               subset=c(data1$answer_main==1 & data1$isindep==1))
summary(reg2.ind.cong) 

##feelings toward majority
reg2.ind.maj<- lm(ft_maj ~ treatment_bipart + treatment_min + policy_sent,
              data=data1,
              subset=c(data1$answer_main==1 & data1$isindep==1))
summary(reg2.ind.maj) 

##########################################
##Output regressions
source("regtable.R")

##working directly for output
setwd(".../output")  ##SET WORKING DIRECTORY HERE

##Pooled models, no interaction - Table 2
outtable.rtf(list("(1) Bill"=reg2.bill, "(2) Congress"=reg2.cong, "(3) Majority"=reg2.maj),
             replacelist=list(c("(Intercept)", "Constant"),
                              c("treatment_bipart", "Ignore Bipartisan"),
                              c("treatment_min", "Ignore Minority"),
                              c("maj_other", "Minority Voters"),
                              c("policy_sent", "Maj. Bill on Sentencing")),
             p.levels =c(0.10,0.05,0.01,0.001),
             scientific = 5,
             digits = 3,
             p.levels.labels=c("^", "*","**","***"),
             "Table 2.rtf")

##Models with all conditions, excluding independents - Table 3
outtable.rtf(list("(1) Bill"=reg3.bill, "(2) Congress"=reg3.cong, "(3) Majority"=reg3.maj),
             replacelist=list(c("(Intercept)", "Constant"),
                              c("treatment_bipart", "Ignore Bipartisan"),
                              c("treatment_min", "Ignore Minority"),
                              c("maj_other", "Minority Voters"),
                              c("treatment_bipart:maj_other", "Bipartisan X Minority Voters"),
                              c("maj_other:treatment_min", "Minority X Minority Voters"),
                              c("policy_sent", "Maj. Bill on Sentencing")),
             p.levels =c(0.10,0.05,0.01,0.001),
             scientific = 5,
             digits = 3,
             p.levels.labels=c("^", "*","**","***"),
             "Table 3.rtf")

##Appendix manipulation check correct - Appendix Table E1
outtable.rtf(list("(1) Bill"=reg3.manip.bill, "(2) Congress"=reg3.manip.cong, "(3) Majority"=reg3.manip.maj),
             replacelist=list(c("(Intercept)", "Constant"),
                              c("treatment_bipart", "Ignore Bipartisan"),
                              c("treatment_min", "Ignore Minority"),
                              c("maj_other", "Minority Voters"),
                              c("treatment_bipart:maj_other", "Bipartisan X Minority Voters"),
                              c("maj_other:treatment_min", "Minority X Minority Voters"),
                              c("policy_sent", "Maj. Bill on Sentencing")),
             p.levels =c(0.10,0.05,0.01,0.001),
             scientific = 5,
             digits = 3,
             p.levels.labels=c("^", "*","**","***"),
             "Appendix Table E1.rtf")

##Appendix strong partisans - Appendix Table E2
outtable.rtf(list("(1) Bill"=reg3.stpart.bill, "(2) Congress"=reg3.stpart.cong, "(3) Majority"=reg3.stpart.maj),
             replacelist=list(c("(Intercept)", "Constant"),
                              c("treatment_bipart", "Ignore Bipartisan"),
                              c("treatment_min", "Ignore Minority"),
                              c("maj_other", "Minority Voters"),
                              c("treatment_bipart:maj_other", "Bipartisan X Minority Voters"),
                              c("maj_other:treatment_min", "Minority X Minority Voters"),
                              c("policy_sent", "Maj. Bill on Sentencing")),
             p.levels =c(0.10,0.05,0.01,0.001),
             scientific = 5,
             digits = 3,
             p.levels.labels=c("^", "*","**","***"),
             "Appendix Table E2.rtf")

##Appendix high knowledge -Appendix Table E3
outtable.rtf(list("(1) Bill"=reg3.know.bill, "(2) Congress"=reg3.know.cong, "(3) Majority"=reg3.know.maj),
             replacelist=list(c("(Intercept)", "Constant"),
                              c("treatment_bipart", "Ignore Bipartisan"),
                              c("treatment_min", "Ignore Minority"),
                              c("maj_other", "Minority Voters"),
                              c("treatment_bipart:maj_other", "Bipartisan X Minority Voters"),
                              c("maj_other:treatment_min", "Minority X Minority Voters"),
                              c("policy_sent", "Maj. Bill on Sentencing")),
             p.levels =c(0.10,0.05,0.01,0.001),
             scientific = 5,
             digits = 3,
             p.levels.labels=c("^", "*","**","***"),
             "Appendix Table E3.rtf")

##Just independents - Appendix Table E4
outtable.rtf(list("(1) Bill"=reg2.ind.bill, "(2) Congress"=reg2.ind.cong, "(3) Majority"=reg2.ind.maj),
             replacelist=list(c("(Intercept)", "Constant"),
                              c("treatment_bipart", "Ignore Bipartisan"),
                              c("treatment_min", "Ignore Minority"),
                              c("maj_other", "Minority Voters"),
                              c("treatment_bipart:maj_other", "Bipartisan X Minority Voters"),
                              c("maj_other:treatment_min", "Minority X Minority Voters"),
                              c("policy_sent", "Maj. Bill on Sentencing")),
             p.levels =c(0.10,0.05,0.01,0.001),
             scientific = 5,
             digits = 3,
             p.levels.labels=c("^", "*","**","***"),
             "Appendix Table E4.rtf")




##############################################
##          Plot marginal effects           ##
##############################################

##Analysis with dplyr
library(dplyr)
library(tidyr)
library(infer)
library(ggplot2)
library(gridExtra)
library(ggeffects)
library(margins)


##marginal effect plot resources
#https://cran.r-project.org/web/packages/sjPlot/vignettes/plot_marginal_effects.html
#https://strengejacke.github.io/ggeffects/
####For a resource, see: http://www.statsblogs.com/2013/08/27/creating-marginal-effect-plots-for-linear-regression-models-in-r/, which is the R version of the Brambor, Golder, et al. resource: http://mattgolder.com/files/interactions/interaction1.pdf


##Marginal effects of Table 3
######################################
##Manual and use tibble to get to ggplot
##Bill
m.bill<- lm(bill ~ treatment_bipart*maj_other + treatment_min*maj_other + policy_sent,
            data=data1,
            subset=c(data1$ispureind==0 & data1$answer_main==1))

# pull out coefficient estimates
bill.beta.hat <- coef(m.bill)
bill.beta.hat

# pull out the covariance matrix
bill.cov <- vcov(m.bill)
bill.cov

# a set of values of z to compute the (instantaneous)
# effect of x
z0 <- seq(min(data1$maj_other, na.rm=TRUE), max(data1$maj_other, na.rm=TRUE), length.out = 2)
z0

##1) ignore bipartisan
# calculate the instantaneous effect of x as z varies
bill.dy.dx.bipart <- bill.beta.hat["treatment_bipart"] + bill.beta.hat["treatment_bipart:maj_other"]*z0
bill.dy.dx.bipart

# calculate the standard error of each estimated effect
bill.se.dy.dx.bipart <- sqrt(bill.cov["treatment_bipart", "treatment_bipart"] + 
                               z0^2*bill.cov["treatment_bipart:maj_other", "treatment_bipart:maj_other"] + 
                               2*z0*bill.cov["treatment_bipart", "treatment_bipart:maj_other"])
bill.se.dy.dx.bipart

# calculate upper and lower bounds of a 95% CI 
bill.upr.bipart <- bill.dy.dx.bipart + 1.96*bill.se.dy.dx.bipart
bill.lwr.bipart <- bill.dy.dx.bipart - 1.96*bill.se.dy.dx.bipart

##2) ignore minority
# calculate the instantaneous effect of x as z varies
bill.dy.dx.min <- bill.beta.hat["treatment_min"] + bill.beta.hat["maj_other:treatment_min"]*z0
bill.dy.dx.min

# calculate the standard error of each estimated effect
bill.se.dy.dx.min <- sqrt(bill.cov["treatment_min", "treatment_min"] + 
                            z0^2*bill.cov["maj_other:treatment_min", "maj_other:treatment_min"] + 
                            2*z0*bill.cov["treatment_min", "maj_other:treatment_min"])
bill.se.dy.dx.min

# calculate upper and lower bounds of a 95% CI 
bill.upr.min <- bill.dy.dx.min + 1.96*bill.se.dy.dx.min
bill.lwr.min <- bill.dy.dx.min - 1.96*bill.se.dy.dx.min

##combine as tibble
margins.bill<- tibble(treatment=c("Ignore Bipartisan", "Ignore Bipartisan", "Ignore Minority", "Ignore Minority"), 
                      party=c("Majority Voters", "Minority Voters", "Majority Voters", "Minority Voters"), 
                      y=c(bill.dy.dx.bipart, bill.dy.dx.min), se=c(bill.se.dy.dx.bipart, bill.se.dy.dx.min), 
                      upr=c(bill.upr.bipart, bill.upr.min), lwr=c(bill.lwr.bipart, bill.lwr.min))
margins.bill

fig2a<- ggplot(margins.bill) +
  geom_errorbar(aes(x=party, ymin=lwr, ymax=upr), ##95% CI
                width=.15) +
  geom_point(aes(x=party, y=y), size=2) + # add the points on
  facet_grid(~treatment) + # split into plots, side by side
  scale_y_continuous(limits=c(-.25,.075)) + 
  theme(axis.text=element_text(size=10), axis.title.y = element_text(size = 10),
        plot.title = element_text(size=10))+
  theme(axis.ticks.x=element_blank(), axis.title.x=element_blank(),
        #axis.title.y=element_blank(),
        strip.text.x = element_text(size=10)) + # how to change facet label font size
  ggtitle("Dependent Variable: Bill Support") + ylab("Marginal Effect of Treatment") +
  geom_hline(yintercept=0, color="grey")


##############################################
##cong
m.cong<- lm(cong ~ treatment_bipart*maj_other + treatment_min*maj_other + policy_sent,
            data=data1,
            subset=c(data1$ispureind==0 & data1$answer_main==1))

# pull out coefficient estimates
cong.beta.hat <- coef(m.cong)
cong.beta.hat

# pull out the covariance matrix
cong.cov <- vcov(m.cong)
cong.cov

# a set of values of z to compute the (instantaneous)
# effect of x
z0 <- seq(min(data1$maj_other, na.rm=TRUE), max(data1$maj_other, na.rm=TRUE), length.out = 2)
z0

##1) ignore bipartisan
# calculate the instantaneous effect of x as z varies
cong.dy.dx.bipart <- cong.beta.hat["treatment_bipart"] + cong.beta.hat["treatment_bipart:maj_other"]*z0
cong.dy.dx.bipart

# calculate the standard error of each estimated effect
cong.se.dy.dx.bipart <- sqrt(cong.cov["treatment_bipart", "treatment_bipart"] + 
                               z0^2*cong.cov["treatment_bipart:maj_other", "treatment_bipart:maj_other"] + 
                               2*z0*cong.cov["treatment_bipart", "treatment_bipart:maj_other"])
cong.se.dy.dx.bipart

# calculate upper and lower bounds of a 95% CI 
cong.upr.bipart <- cong.dy.dx.bipart + 1.96*cong.se.dy.dx.bipart
cong.lwr.bipart <- cong.dy.dx.bipart - 1.96*cong.se.dy.dx.bipart

##2) ignore minority
# calculate the instantaneous effect of x as z varies
cong.dy.dx.min <- cong.beta.hat["treatment_min"] + cong.beta.hat["maj_other:treatment_min"]*z0
cong.dy.dx.min

# calculate the standard error of each estimated effect
cong.se.dy.dx.min <- sqrt(cong.cov["treatment_min", "treatment_min"] + 
                            z0^2*cong.cov["maj_other:treatment_min", "maj_other:treatment_min"] + 
                            2*z0*cong.cov["treatment_min", "maj_other:treatment_min"])
cong.se.dy.dx.min

# calculate upper and lower bounds of a 95% CI 
cong.upr.min <- cong.dy.dx.min + 1.96*cong.se.dy.dx.min
cong.lwr.min <- cong.dy.dx.min - 1.96*cong.se.dy.dx.min

##combine as tibble
margins.cong<- tibble(treatment=c("Ignore Bipartisan", "Ignore Bipartisan", "Ignore Minority", "Ignore Minority"), 
                      party=c("Majority Voters", "Minority Voters", "Majority Voters", "Minority Voters"), 
                      y=c(cong.dy.dx.bipart, cong.dy.dx.min), se=c(cong.se.dy.dx.bipart, cong.se.dy.dx.min), 
                      upr=c(cong.upr.bipart, cong.upr.min), lwr=c(cong.lwr.bipart, cong.lwr.min))
margins.cong

fig2b<- ggplot(margins.cong) +
  geom_errorbar(aes(x=party, ymin=lwr, ymax=upr), ##95% CI
                width=.15) +
  geom_point(aes(x=party, y=y), size=2) + # add the points on
  facet_grid(~treatment) + # split into plots, side by side
  scale_y_continuous(limits=c(-.25,.075)) + 
  theme(axis.text=element_text(size=10), axis.title.y = element_text(size = 10),
        plot.title = element_text(size=10))+
  theme(axis.ticks.x=element_blank(), axis.title.x=element_blank(),
        #axis.title.y=element_blank(),
        strip.text.x = element_text(size=10)) + # how to change facet label font size
  ggtitle("Dependent Variable: Confidence in Congress") + ylab("Marginal Effect of Treatment") +
  geom_hline(yintercept=0, color="grey")


##############################################
##maj
m.maj<- lm(ft_maj ~ treatment_bipart*maj_other + treatment_min*maj_other + policy_sent,
           data=data1,
           subset=c(data1$ispureind==0 & data1$answer_main==1))

# pull out coefficient estimates
maj.beta.hat <- coef(m.maj)
maj.beta.hat

# pull out the covariance matrix
maj.cov <- vcov(m.maj)
maj.cov

# a set of values of z to compute the (instantaneous)
# effect of x
z0 <- seq(min(data1$maj_other, na.rm=TRUE), max(data1$maj_other, na.rm=TRUE), length.out = 2)
z0

##1) ignore bipartisan
# calculate the instantaneous effect of x as z varies
maj.dy.dx.bipart <- maj.beta.hat["treatment_bipart"] + maj.beta.hat["treatment_bipart:maj_other"]*z0
maj.dy.dx.bipart

# calculate the standard error of each estimated effect
maj.se.dy.dx.bipart <- sqrt(maj.cov["treatment_bipart", "treatment_bipart"] + 
                              z0^2*maj.cov["treatment_bipart:maj_other", "treatment_bipart:maj_other"] + 
                              2*z0*maj.cov["treatment_bipart", "treatment_bipart:maj_other"])
maj.se.dy.dx.bipart

# calculate upper and lower bounds of a 95% CI 
maj.upr.bipart <- maj.dy.dx.bipart + 1.96*maj.se.dy.dx.bipart
maj.lwr.bipart <- maj.dy.dx.bipart - 1.96*maj.se.dy.dx.bipart

##2) ignore minority
# calculate the instantaneous effect of x as z varies
maj.dy.dx.min <- maj.beta.hat["treatment_min"] + maj.beta.hat["maj_other:treatment_min"]*z0
maj.dy.dx.min

# calculate the standard error of each estimated effect
maj.se.dy.dx.min <- sqrt(maj.cov["treatment_min", "treatment_min"] + 
                           z0^2*maj.cov["maj_other:treatment_min", "maj_other:treatment_min"] + 
                           2*z0*maj.cov["treatment_min", "maj_other:treatment_min"])
maj.se.dy.dx.min

# calculate upper and lower bounds of a 95% CI 
maj.upr.min <- maj.dy.dx.min + 1.96*maj.se.dy.dx.min
maj.lwr.min <- maj.dy.dx.min - 1.96*maj.se.dy.dx.min

##combine as tibble
margins.maj<- tibble(treatment=c("Ignore Bipartisan", "Ignore Bipartisan", "Ignore Minority", "Ignore Minority"), 
                     party=c("Majority Voters", "Minority Voters", "Majority Voters", "Minority Voters"), 
                     y=c(maj.dy.dx.bipart, maj.dy.dx.min), se=c(maj.se.dy.dx.bipart, maj.se.dy.dx.min), 
                     upr=c(maj.upr.bipart, maj.upr.min), lwr=c(maj.lwr.bipart, maj.lwr.min))
margins.maj

fig2c<- ggplot(margins.maj) +
  geom_errorbar(aes(x=party, ymin=lwr, ymax=upr), ##95% CI
                width=.15) +
  geom_point(aes(x=party, y=y), size=2) + # add the points on
  facet_grid(~treatment) + # split into plots, side by side
  scale_y_continuous(limits=c(-.25,.075)) + 
  theme(axis.text=element_text(size=10), axis.title.y = element_text(size = 10),
        plot.title = element_text(size=10))+
  theme(axis.ticks.x=element_blank(), axis.title.x=element_blank(),
        #axis.title.y=element_blank(),
        strip.text.x = element_text(size=10)) + # how to change facet label font size
  ggtitle("Dependent Variable: Feelings Toward Majority Party") + ylab("Marginal Effect of Treatment") +
  geom_hline(yintercept=0, color="grey")


#######################################
##combine plots
grid.arrange(fig2a, fig2b, fig2c, nrow=2)
fig2.g<- arrangeGrob(fig2a, fig2b, fig2c, nrow=2)
ggsave("figure 2_study 1 interactions.tiff", fig2.g, height=10, width=12, dpi=350)



#####################################
##    Time on Vignettes            ##
#####################################
##categorical variable for treatment
data1$treatment_category<- ifelse(data1$treatment_bipart==1, "Ignore Bipartisan",
                                  ifelse(data1$treatment_min==1, "Ignore Minority", "Control"))
summary(as.factor(data1$treatment_category))

##Control
summary(data1$vig_durat_cont[data1$answer_main==1 & data1$treatment_category=="Control"])
##Treatment
summary(data1$vig_durat_treat[data1$answer_main==1 & data1$treatment_category!="Control"])

##########################################
##  Ind and Group level check of FMC    ##
##########################################
##maj: 1 "DemMaj" 2 "GOPMaj"
##manip_chk: 1 "Republican party" 2 "Democratic party" 3 "wasn't specified"
xtabs(~data1$maj[data1$answer_main==1] + data1$manip_chk[data1$answer_main==1])

##individual level percent correct
summary(as.factor(data1$manip_correct[data1$answer_main==1]))
848/(616+848)
prop.table(table(data1$manip_correct[data1$answer_main==1])) ##54%

##if assigned to Democratic majority, what pct said majority was Democrats?
332/(229+332+177) ##44.9% (main error was saying Republicans, which was ACTUAL current majority)
##if assigned to Republican majority, what pct said majority was Democrats?
58/(516+58+128) ##8.26%
##if assigned to Dem majority, how much more likely to say Dem was majority?
0.4498645/0.08262108


#########################################################
##  Check on those assigned Republican majority        ##
##  Because much more successful on manipulation check ##
#########################################################
##Pool all conditions, exclude independents - appendix footnote 8
##bill evaluation
reg3.gop.bill<- lm(bill ~ treatment_bipart*maj_other + treatment_min*maj_other + policy_sent,
                   data=data1,
                   subset=c(data1$ispureind==0 & data1$answer_main==1 & data1$maj==2))
summary(reg3.gop.bill) 

##congress
reg3.gop.cong<- lm(cong ~ treatment_bipart*maj_other + treatment_min*maj_other + policy_sent,
               data=data1,
               subset=c(data1$ispureind==0 & data1$answer_main==1 & data1$maj==2))
summary(reg3.gop.cong) 

##feelings toward majority
reg3.gop.maj<- lm(ft_maj ~ treatment_bipart*maj_other + treatment_min*maj_other + policy_sent,
              data=data1,
              subset=c(data1$ispureind==0 & data1$answer_main==1 & data1$maj==2))
summary(reg3.gop.maj) 
